import 'package:flutter/material.dart';
import 'package:flutter_eve_plugin/constants/font_family.dart';
import 'package:flutter_eve_plugin/constants/font_weight.dart';
import 'package:flutter_eve_plugin/model/ye_xiu/achieves/archieves_role_entity.dart';
import 'package:flutter_eve_plugin/utils/image_util.dart';
import 'package:flutter_eve_plugin/utils/screen_util.dart';

class ArchivesAttrDescWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    List<ArchievesRoleRoleinfoProperty> list = roleinfo?.property;
    ArchievesRoleRoleinfoProperty info =
        ArchievesRoleRoleinfoProperty(name: '', userLevel: 1, level: 1);
    bool isAchieve = false;
    if (list != null && list.length > 0) {
      info = list[0];
      if (info.level != null && info.userLevel != null) {
        isAchieve = info.userLevel >= info.level;
      }
    }
    return Container(
      padding: EdgeInsets.only(
          left: setRatio(21), top: setRatio(19), right: setRatio(31)),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        crossAxisAlignment: CrossAxisAlignment.center,
        children: <Widget>[
          Text.rich(TextSpan(
              style: TextStyle(
                  decoration: TextDecoration.none,
                  color: Color(0xFFFFFFFF),
                  fontFamily: FontFamily.PINGFANG,
                  fontWeight: FontWeightCustom.PF_Medium,
                  fontSize: setTextSp(13)),
              children: [
                TextSpan(text: '下一级需要人物【${info.name ?? ''}】能力到达 '),
                TextSpan(
                    text: 'Lv.${info.level ?? 0}',
                    style: TextStyle(color: Color(0xFFFD8D8E))),
              ])),
          Container(
            width: setRatio(55),
            height: setRatio(20),
            decoration: BoxDecoration(
                image: DecorationImage(
                    image: AssetImage(imageUtilYeXiu((isAchieve
                        ? 'archives/icon_archivers_reach_btn@3x'
                        : 'archives/icon_archivers_lack_btn@3x') ?? '')))),
          )
        ],
      ),
    );
  }

  final ArchievesRoleRoleinfo roleinfo;

  const ArchivesAttrDescWidget({Key key, this.roleinfo}) : super(key: key);
}
